package com.glink.manage.service.Impl;

import com.glink.manage.common.Constants;
import com.glink.manage.domain.AppVersionManageBean;
import com.glink.manage.mapper.AppVersionManageMapper;
import com.glink.manage.service.AppVersionManageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * @author  qiushaoshan
 * @since 2025-01-16
 */
@Service
public class AppVersionManageServiceImpl extends ServiceImpl<AppVersionManageMapper, AppVersionManageBean> implements AppVersionManageService {

    /**
     * 查询最近一个APP版本记录
     *
     * @return APP版本
     */
    @Override
    public AppVersionManageBean findOneOrderByCreateTimeDesc() {
        return this.lambdaQuery().orderByDesc(AppVersionManageBean::getCreateTime).last(Constants.LAST_SQL).one();
    }

    /**
     * 根据ID排除查询一个APP版本记录
     *
     * @param appId appID
     * @return app版本
     */
    @Override
    public AppVersionManageBean findOneByObjIdNotOrderByCreateTimeDesc(String appId) {
        return this.lambdaQuery()
                .ne(AppVersionManageBean::getObjId, appId)
                .orderByDesc(AppVersionManageBean::getCreateTime)
                .last(Constants.LAST_SQL).one();
    }
}
